package org.bling.star.client.contollers;

import org.bling.star.client.server.send.ConnectService;
import org.bling.star.common.command.ExitCommand;
import org.bling.star.common.command.JoinCommand;
import org.bling.star.common.command.TalkingCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/connect")
public class Controller {
    @Autowired
    ConnectService connectService;
    @RequestMapping("/create")
    public void create() {
        connectService.createTalkingPool();
    }

    @RequestMapping("/join")
    public void join(@RequestBody JoinCommand joinCommand) {
        connectService.join(joinCommand);
    }

    @RequestMapping("/broadcast")
    public void broadcast(@RequestBody TalkingCommand talkingCommand) {
        connectService.talking(talkingCommand);
    }
    @RequestMapping("/exit")
    public void exit(@RequestBody ExitCommand exitCommand) {
        connectService.exit(exitCommand);
    }
    @RequestMapping("/close")
    public void close() {
        connectService.close();
    }
}
